#include <iostream>
#include <stack>
#include <cstring>
#define MAXN 1000
using namespace std;


struct mem{
	bool nc;
	int num;
	char cac;
};


int main(){
	stack<mem> sta;
	mem now;
	char s;
	for(int i=0;true;i++){
		cin>>s;
//		cout<<i<<" "<<sta.size()<<endl;
		if(s == ';'){
//			cout<<114514;
			while(sta.size() != 0  &&  now.nc  &&  sta.top().nc){
				mem bef=sta.top();
				sta.pop();
				if(sta.top().cac == '+'){
					now.num += bef.num;
				}
				else if(sta.top().cac == '-'){
					now.num = bef.num-now.num;
				}
				else if(sta.top().cac == '*'){
					now.num *= bef.num;
				}
				else if(sta.top().cac == '/'){
					now.num = bef.num/now.num;
				}
//				cout<<now.num<<endl;
				sta.pop();
			}
			if(sta.size() == 0  &&  now.nc)
				break;
			sta.push(now);
			now.nc = true;
			now.num = 0;
		}
		else if(s <= '9'  &&  s >= '0'){
			now.num = now.num*10+(s-'0');
		}
		else{
			if(s == '+'  ||  s == '-'  ||  s == '*'  ||  s == '/'){
				now.nc = false;
				now.cac = s;
			}
		}
	}
//	cout<<s<<endl;
	cout<<now.num;
	return 0;
}
